package com.itheima.reggie.controller;

import com.itheima.reggie.common.ResultInfo;
import com.itheima.reggie.domain.Dish;
import com.itheima.reggie.domain.Setmeal;
import com.itheima.reggie.domain.SetmealDish;
import com.itheima.reggie.service.SetmealService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class SetmealController {
    @Autowired
    private SetmealService setmealService;

    @GetMapping("/setmeal/list")    //查询在售套餐
    public ResultInfo findOnSale(Long categoryId, Integer status) {
        List<Setmeal> setmealList = setmealService.findDishOnSale(categoryId, status);
        return ResultInfo.success(setmealList);
    }

    //  根据套餐的id查询套餐/setmeal/dish/1533405222031527937
    @GetMapping("/setmeal/dish/{id}")    //查看在售套餐具体菜品信息
    public ResultInfo findByIdBrief(@PathVariable("id") Long id) {

        List<SetmealDish> setmealDishes = setmealService.findByIdBrief(id);

        return ResultInfo.success(setmealDishes);
    }
}
